<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta name="description" content="夜间模式">
<meta property="og:type" content="article">
<meta property="og:title" content="夜间模式">
<meta property="og:url" content="http://yoursite.com/2018/10/23/夜间模式/index.html">
<meta property="og:site_name" content="Erhqe">
<meta property="og:description" content="夜间模式">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https://ws1.sinaimg.cn/large/006tNbRwly1fwhvh4zomcg30gg0wen1f.gif">
<meta property="og:image" content="https://ws4.sinaimg.cn/large/006tNbRwly1fwhvy87u5xj30o90w741z.jpg">
<meta property="og:updated_time" content="2019-07-19T05:40:06.081Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="夜间模式">
<meta name="twitter:description" content="夜间模式">
<meta name="twitter:image" content="https://ws1.sinaimg.cn/large/006tNbRwly1fwhvh4zomcg30gg0wen1f.gif">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2018/10/23/夜间模式/"/>





  <title>夜间模式 | Erhqe</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Erhqe</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/10/23/夜间模式/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Erhqe">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/10.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Erhqe">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">夜间模式</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2018-10-23T08:45:40+08:00">
                2018-10-23
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">In</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/夜间模式/" itemprop="url" rel="index">
                    <span itemprop="name">夜间模式</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2018/10/23/夜间模式/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/2018/10/23/夜间模式/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="夜间模式"><a href="#夜间模式" class="headerlink" title="夜间模式"></a>夜间模式<a id="more"></a></h3><p><strong>图片未处理,按钮之类的图片可以用两种图片来实现,网络图没思路</strong></p>
<p><img src="https://ws1.sinaimg.cn/large/006tNbRwly1fwhvh4zomcg30gg0wen1f.gif" alt=""></p>
<p><strong>复习继承图</strong></p>
<p><img src="https://ws4.sinaimg.cn/large/006tNbRwly1fwhvy87u5xj30o90w741z.jpg" alt=""></p>
<p><strong>简单思路,利用单例和单例的BOOL night属性设置单例的颜色属性值,创建UIView的分类去监听夜间模式切换按钮的动态,当按钮事件通知发出时从单例中取出当前模式的颜色给UIView设置颜色</strong></p>
<h4 id="ThemeManager-颜色管理者-H"><a href="#ThemeManager-颜色管理者-H" class="headerlink" title="ThemeManager-颜色管理者.H"></a>ThemeManager-颜色管理者.H</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">#import &lt;UIKit/UIKit.h&gt;</span><br><span class="line"></span><br><span class="line">@interface ThemeManager : NSObject</span><br><span class="line"></span><br><span class="line">/*是否是夜间模式*/</span><br><span class="line">@property(assign,nonatomic,getter=isNight) BOOL night;</span><br><span class="line"></span><br><span class="line">@property(strong,nonatomic)UIColor *themeNormalColor;</span><br><span class="line">@property(strong,nonatomic)UIColor *themeBlackColor;</span><br><span class="line">@property(strong,nonatomic)UIColor *themeRedColor;</span><br><span class="line">@property(strong,nonatomic)UIColor *themeClearColor;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">+ (instancetype)shareInstance;</span><br><span class="line"></span><br><span class="line">@end</span><br></pre></td></tr></table></figure>
<h4 id="ThemeManager-颜色管理者-M"><a href="#ThemeManager-颜色管理者-M" class="headerlink" title="ThemeManager-颜色管理者.M"></a>ThemeManager-颜色管理者.M</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line">#import &quot;ThemeManager.h&quot;</span><br><span class="line"></span><br><span class="line">static ThemeManager *theme;</span><br><span class="line"></span><br><span class="line">@implementation ThemeManager</span><br><span class="line"></span><br><span class="line">+ (instancetype)shareInstance&#123;</span><br><span class="line">    static dispatch_once_t onceToken;</span><br><span class="line">    dispatch_once(&amp;onceToken, ^&#123;</span><br><span class="line">        theme = [[ThemeManager alloc]init];</span><br><span class="line">    &#125;);</span><br><span class="line">    return theme;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">- (void)setNight:(BOOL)night&#123;</span><br><span class="line">    </span><br><span class="line">    if (_night != night) &#123;</span><br><span class="line">        _night = night;</span><br><span class="line">    &#125;</span><br><span class="line">    if (self.isNight) &#123;</span><br><span class="line">        self.themeNormalColor = [UIColor colorWithRed:0.63 green:0.63 blue:0.63 alpha:1];</span><br><span class="line">        self.themeBlackColor = [UIColor darkGrayColor];</span><br><span class="line">        self.themeRedColor = [UIColor colorWithRed:1.06 green:0.31 blue:0.24 alpha:1];</span><br><span class="line">        </span><br><span class="line">    &#125;else&#123;</span><br><span class="line">        self.themeNormalColor = [UIColor whiteColor];</span><br><span class="line">        self.themeBlackColor = [UIColor blackColor];</span><br><span class="line">        self.themeRedColor = [UIColor colorWithRed:211 / 255.0 green:19 / 255.0 blue:65 / 255.0 alpha:1];</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    static dispatch_once_t onceToken;</span><br><span class="line">    dispatch_once(&amp;onceToken, ^&#123;</span><br><span class="line">        self.themeClearColor = [UIColor clearColor];</span><br><span class="line">    &#125;);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">@end</span><br></pre></td></tr></table></figure>
<h4 id="UIView-Theme-UIView分类-H"><a href="#UIView-Theme-UIView分类-H" class="headerlink" title="UIView+Theme-UIView分类.H"></a>UIView+Theme-UIView分类.H</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">#import &lt;UIKit/UIKit.h&gt;</span><br><span class="line">//	可以理解为主题,如果需要配置自己的颜色自己可以添加,注意需要对应ThemeManager中的颜色</span><br><span class="line">typedef NS_ENUM(NSUInteger, ThemeType) &#123;</span><br><span class="line">    ThemeTypeNormal,        // 白→深灰</span><br><span class="line">    ThemeTypeBlack,          // 黑→ 灰    (文字比较合适)</span><br><span class="line">    ThemeTypeRed,           //红 → 暗红</span><br><span class="line">    ThemeTypeClear          // 白天夜间 透明</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">@interface UIView (Theme)</span><br><span class="line"></span><br><span class="line">/*Type作用保存下边方法的参数*/</span><br><span class="line">@property(assign,nonatomic) id type;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">/*设置颜色类型和对应颜色*/</span><br><span class="line">- (void)nightWithType:(ThemeType)type;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">@end</span><br></pre></td></tr></table></figure>
<h4 id="UIView-Theme-UIView分类-M"><a href="#UIView-Theme-UIView分类-M" class="headerlink" title="UIView+Theme-UIView分类.M"></a>UIView+Theme-UIView分类.M</h4><p><strong>UIView的子类修改背景色</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line">#import &quot;UIView+Theme.h&quot;</span><br><span class="line">#import &quot;ThemeManager.h&quot;	// 导入颜色管理者</span><br><span class="line">#import &lt;objc/runtime.h&gt;	// 需要用runtime实现 id type的set方法和get方法</span><br><span class="line"></span><br><span class="line">@implementation UIView (Theme)</span><br><span class="line"></span><br><span class="line">// runtime set方法</span><br><span class="line">- (void)setType:(id)type&#123;</span><br><span class="line">    objc_setAssociatedObject(self, @selector(type), type, OBJC_ASSOCIATION_COPY_NONATOMIC);</span><br><span class="line">&#125;</span><br><span class="line">// runtime get方法</span><br><span class="line">- (id)type&#123;</span><br><span class="line">    return objc_getAssociatedObject(self, @selector(type));</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">/**开始监听*/</span><br><span class="line">- (void)startMonitor&#123;</span><br><span class="line">    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(changeColor) name:@&quot;CHANGECOLOR&quot; object:nil];</span><br><span class="line">    </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">//*修改颜色/</span><br><span class="line">- (void)changeColor&#123;</span><br><span class="line">    NSLog(@&quot;UIViewCategory&quot;);</span><br><span class="line">    switch ([self.type integerValue]) &#123;</span><br><span class="line">        case ThemeTypeNormal:</span><br><span class="line">            self.backgroundColor = [ThemeManager shareInstance].themeNormalColor;</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeBlack:</span><br><span class="line">            self.backgroundColor = [ThemeManager shareInstance].themeBlackColor;</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeRed:</span><br><span class="line">            self.backgroundColor = [ThemeManager shareInstance].themeRedColor;</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeClear:</span><br><span class="line">            self.backgroundColor = [ThemeManager shareInstance].themeClearColor;</span><br><span class="line">            break;</span><br><span class="line"></span><br><span class="line">        default:</span><br><span class="line">            break;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">/*设置颜色类型和对应颜色*/</span><br><span class="line">- (void)nightWithType:(ThemeType)type&#123;</span><br><span class="line">    self.type = [NSNumber numberWithInteger:type];</span><br><span class="line">    [self changeColor];</span><br><span class="line">    [self startMonitor];</span><br><span class="line">    // 调用设置字体颜色的方法</span><br><span class="line">    [self initTextColor];</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">/*设置字体颜色的方法*/</span><br><span class="line">- (void)initTextColor&#123;</span><br><span class="line">	//在子类的分类中重写会 ,首先调用父类的(也是本类)方法,在去UILabel+Theme中调用initTextColor所以子类的可以重写这个方法设置属性之类</span><br><span class="line">&#125;</span><br><span class="line">@end</span><br></pre></td></tr></table></figure>
<h4 id="UINavigationBar-Theme-导航条分类-M"><a href="#UINavigationBar-Theme-导航条分类-M" class="headerlink" title="UINavigationBar+Theme-导航条分类.M"></a>UINavigationBar+Theme-导航条分类.M</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line">#import &quot;UINavigationBar+Theme.h&quot;</span><br><span class="line">#import &quot;ThemeManager.h&quot;</span><br><span class="line">#import &quot;UIView+Theme.h&quot;</span><br><span class="line"></span><br><span class="line">@implementation UINavigationBar (Theme)</span><br><span class="line"></span><br><span class="line">- (void)changeColor&#123;</span><br><span class="line">//    [super changeColor];</span><br><span class="line">    </span><br><span class="line">    switch ([self.type integerValue]) &#123;</span><br><span class="line">        case ThemeTypeNormal:</span><br><span class="line">            [self setBarTintColor:[ThemeManager shareInstance].themeNormalColor];</span><br><span class="line">            [self setBackgroundColor:[UIColor clearColor]];</span><br><span class="line">            [self setTitleTextAttributes:@&#123;NSForegroundColorAttributeName : [ThemeManager shareInstance].themeBlackColor&#125;];</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeRed:</span><br><span class="line">            </span><br><span class="line">            [self setBarTintColor:[ThemeManager shareInstance].themeRedColor];</span><br><span class="line">            [self setBackgroundColor:[UIColor clearColor]];</span><br><span class="line">            [self setTitleTextAttributes:@&#123;NSForegroundColorAttributeName : [ThemeManager shareInstance].themeBlackColor&#125;];</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeBlack:</span><br><span class="line">            </span><br><span class="line">            [self setBarTintColor:[ThemeManager shareInstance].themeBlackColor];</span><br><span class="line">            [self setBackgroundColor:[UIColor clearColor]];</span><br><span class="line">            [self setTitleTextAttributes:@&#123;NSForegroundColorAttributeName : [ThemeManager shareInstance].themeBlackColor&#125;];</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeClear:</span><br><span class="line">            </span><br><span class="line">            [self setBarTintColor:[ThemeManager shareInstance].themeClearColor];</span><br><span class="line">            [self setBackgroundColor:[UIColor clearColor]];</span><br><span class="line">            [self setTitleTextAttributes:@&#123;NSForegroundColorAttributeName : [ThemeManager shareInstance].themeBlackColor&#125;];</span><br><span class="line">            break;</span><br><span class="line">            </span><br><span class="line">        default:</span><br><span class="line">            break;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    </span><br><span class="line">    </span><br><span class="line">    //  改变电池栏style</span><br><span class="line">    if ([ThemeManager shareInstance].isNight) &#123;</span><br><span class="line">        [self setBarStyle:UIBarStyleBlackTranslucent];</span><br><span class="line">    &#125;else&#123;</span><br><span class="line">        [self setBarStyle:UIBarStyleDefault];</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">@end</span><br></pre></td></tr></table></figure>
<h4 id="UITabBarItem-Theme-H-菜单按钮文字颜色"><a href="#UITabBarItem-Theme-H-菜单按钮文字颜色" class="headerlink" title="UITabBarItem+Theme.H-菜单按钮文字颜色"></a>UITabBarItem+Theme.H-菜单按钮文字颜色</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">#import &lt;UIKit/UIKit.h&gt;</span><br><span class="line">#import &quot;UIView+Theme.h&quot;</span><br><span class="line"></span><br><span class="line">//由于 UIBarItem不是继承自UIView,需要重新写属性及方法</span><br><span class="line">@interface UITabBarItem (Theme)</span><br><span class="line"></span><br><span class="line">/*Type*/</span><br><span class="line">@property(assign,nonatomic) id type;</span><br><span class="line"></span><br><span class="line">/*设置颜色类型和对应颜色*/</span><br><span class="line">- (void)nightWithType:(ThemeType)type;</span><br><span class="line"></span><br><span class="line">@end</span><br></pre></td></tr></table></figure>
<h4 id="UITabBarItem-Theme-M-也是一样的"><a href="#UITabBarItem-Theme-M-也是一样的" class="headerlink" title="UITabBarItem+Theme.M-也是一样的"></a>UITabBarItem+Theme.M-也是一样的</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br></pre></td><td class="code"><pre><span class="line">#import &quot;UITabBarItem+Theme.h&quot;</span><br><span class="line">#import &lt;objc/runtime.h&gt;</span><br><span class="line">#import &quot;ThemeManager.h&quot;</span><br><span class="line">#import &quot;UIView+Theme.h&quot;</span><br><span class="line"></span><br><span class="line">@implementation UITabBarItem (Theme)</span><br><span class="line"></span><br><span class="line">- (void)setType:(id)type&#123;</span><br><span class="line">    objc_setAssociatedObject(self, @selector(type), type, OBJC_ASSOCIATION_ASSIGN);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">-(id)type&#123;</span><br><span class="line">    return objc_getAssociatedObject(self, @selector(type));</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">/*开始监听*/</span><br><span class="line">- (void)startMonitor&#123;</span><br><span class="line">    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(changeColor) name:@&quot;CHANGECOLOR&quot; object:nil];</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">/*设置颜色类型和对应颜色*/</span><br><span class="line">- (void)nightWithType:(ThemeType)type&#123;</span><br><span class="line">    self.type = [NSNumber numberWithInteger:type];</span><br><span class="line">    [self startMonitor];</span><br><span class="line">    [self changeColor];</span><br><span class="line">    </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">/**修改颜色*/</span><br><span class="line">- (void)changeColor&#123;</span><br><span class="line">    </span><br><span class="line">    NSMutableDictionary *selectedt = [NSMutableDictionary dictionary];</span><br><span class="line">//    NSMutableDictionary *normal = [NSMutableDictionary dictionary];</span><br><span class="line">    switch ([self.type integerValue]) &#123;</span><br><span class="line">        case ThemeTypeNormal:</span><br><span class="line">            </span><br><span class="line">            selectedt = [NSMutableDictionary dictionaryWithObject:[ThemeManager shareInstance].themeNormalColor forKey:NSForegroundColorAttributeName];</span><br><span class="line">            [self setTitleTextAttributes:selectedt forState:UIControlStateSelected];</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeBlack:</span><br><span class="line">            </span><br><span class="line">            selectedt = [NSMutableDictionary dictionaryWithObject:[ThemeManager shareInstance].themeBlackColor forKey:NSForegroundColorAttributeName];</span><br><span class="line">            [self setTitleTextAttributes:selectedt forState:UIControlStateSelected];</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeRed:</span><br><span class="line">            </span><br><span class="line">            selectedt = [NSMutableDictionary dictionaryWithObject:[ThemeManager shareInstance].themeRedColor forKey:NSForegroundColorAttributeName];</span><br><span class="line">            [self setTitleTextAttributes:selectedt forState:UIControlStateSelected];</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeClear:</span><br><span class="line">            </span><br><span class="line">            selectedt = [NSMutableDictionary dictionaryWithObject:[ThemeManager shareInstance].themeClearColor forKey:NSForegroundColorAttributeName];</span><br><span class="line">            [self setTitleTextAttributes:selectedt forState:UIControlStateSelected];</span><br><span class="line">            break;</span><br><span class="line">            </span><br><span class="line">        default:</span><br><span class="line">            break;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="UITabBar-Theme-M-菜单栏底部"><a href="#UITabBar-Theme-M-菜单栏底部" class="headerlink" title="UITabBar+Theme.M-菜单栏底部"></a>UITabBar+Theme.M-菜单栏底部</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">#import &quot;UITabBar+Theme.h&quot;</span><br><span class="line">#import &quot;ThemeManager.h&quot;</span><br><span class="line">#import &quot;UIView+Theme.h&quot;</span><br><span class="line">@implementation UITabBar (Theme)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">- (void)changeColor&#123;</span><br><span class="line">    switch ([self.type integerValue]) &#123;</span><br><span class="line">        case ThemeTypeNormal:</span><br><span class="line">            [self setBarTintColor:[ThemeManager shareInstance].themeNormalColor];</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeBlack:</span><br><span class="line">            [self setBarTintColor:[ThemeManager shareInstance].themeBlackColor];</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeRed:</span><br><span class="line">            [self setBarTintColor:[ThemeManager shareInstance].themeRedColor];</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeClear:</span><br><span class="line">            [self setBarTintColor:[ThemeManager shareInstance].themeClearColor];</span><br><span class="line">            break;</span><br><span class="line">            </span><br><span class="line">        default:</span><br><span class="line">            break;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">@end</span><br></pre></td></tr></table></figure>
<h4 id="UILabel-Theme-M"><a href="#UILabel-Theme-M" class="headerlink" title="UILabel+Theme.M"></a>UILabel+Theme.M</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line">#import &quot;UILabel+Theme.h&quot;</span><br><span class="line">#import &quot;UIView+Theme.h&quot;</span><br><span class="line">#import &quot;ThemeManager.h&quot;</span><br><span class="line"></span><br><span class="line">#import &lt;objc/runtime.h&gt;</span><br><span class="line">@implementation UILabel (Theme)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">- (void)changeColor&#123;</span><br><span class="line">    switch ([self.type integerValue]) &#123;</span><br><span class="line">        case ThemeTypeNormal:</span><br><span class="line">            self.textColor = [ThemeManager shareInstance].themeNormalColor;</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeBlack:</span><br><span class="line">            self.textColor = [ThemeManager shareInstance].themeBlackColor;</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeRed:</span><br><span class="line">            self.textColor = [ThemeManager shareInstance].themeRedColor;</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeClear:</span><br><span class="line">            self.textColor = [ThemeManager shareInstance].themeClearColor;</span><br><span class="line">            break;</span><br><span class="line">            </span><br><span class="line">        default:</span><br><span class="line">            break;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">- (void)initTextColor&#123;</span><br><span class="line">    switch ([self.type integerValue]) &#123;</span><br><span class="line">        case ThemeTypeNormal:</span><br><span class="line">            self.textColor = [ThemeManager shareInstance].themeNormalColor;</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeBlack:</span><br><span class="line">            self.textColor = [ThemeManager shareInstance].themeBlackColor;</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeRed:</span><br><span class="line">            self.textColor = [ThemeManager shareInstance].themeRedColor;</span><br><span class="line">            break;</span><br><span class="line">        case ThemeTypeClear:</span><br><span class="line">            self.textColor = [ThemeManager shareInstance].themeClearColor;</span><br><span class="line">            break;</span><br><span class="line">            </span><br><span class="line">        default:</span><br><span class="line">            break;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">@end</span><br></pre></td></tr></table></figure>
<h4 id="ViewController-中使用"><a href="#ViewController-中使用" class="headerlink" title="ViewController-中使用"></a>ViewController-中使用</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br></pre></td><td class="code"><pre><span class="line">#import &quot;ViewController.h&quot;</span><br><span class="line">#import &quot;ThemeManager.h&quot;</span><br><span class="line">#import &quot;UIButton+Theme.h&quot;</span><br><span class="line">#import &quot;UIView+Theme.h&quot;</span><br><span class="line">#import &quot;ThemeManager.h&quot;</span><br><span class="line">#import &quot;UITabBarItem+Theme.h&quot;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">@interface ViewController ()</span><br><span class="line"></span><br><span class="line">@end</span><br><span class="line"></span><br><span class="line">@implementation ViewController</span><br><span class="line"></span><br><span class="line">- (void)viewDidLoad &#123;</span><br><span class="line">    [super viewDidLoad];</span><br><span class="line">    </span><br><span class="line">    [self.view nightWithType:ThemeTypeNormal];</span><br><span class="line">    </span><br><span class="line">    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];</span><br><span class="line">    btn.frame = CGRectMake(100, 100, 100, 50);</span><br><span class="line">    [btn setTitle:@&quot;按钮文字&quot; forState:UIControlStateNormal];</span><br><span class="line">    [self.view addSubview:btn];</span><br><span class="line">    [btn nightTextType:ThemeTypeRed];</span><br><span class="line">    </span><br><span class="line">    </span><br><span class="line">    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(150, 300, 200, 50)];</span><br><span class="line">    label.text = @&quot;夜间模式文字颜色测试观察&quot;;</span><br><span class="line">    label.numberOfLines = 0;</span><br><span class="line">    [self.view addSubview:label];</span><br><span class="line">    [label nightWithType:ThemeTypeBlack];</span><br><span class="line">    </span><br><span class="line">    </span><br><span class="line">    </span><br><span class="line">    UISwitch *sw = [[UISwitch alloc]initWithFrame:CGRectMake(200, 200, 50, 35)];</span><br><span class="line">    sw.onTintColor = [UIColor orangeColor];</span><br><span class="line">    sw.thumbTintColor = [UIColor redColor];</span><br><span class="line">    [sw addTarget:self action:@selector(changeTheme) forControlEvents:UIControlEventValueChanged];</span><br><span class="line">    [self.view addSubview:sw];</span><br><span class="line">    </span><br><span class="line">    </span><br><span class="line">    [self.navigationController.navigationBar nightWithType:ThemeTypeNormal];</span><br><span class="line">    [self.navigationController.tabBarItem nightWithType:ThemeTypeBlack];</span><br><span class="line">    [self.navigationController.tabBarController.tabBar nightWithType:ThemeTypeRed];</span><br><span class="line">    </span><br><span class="line">    self.navigationItem.title = @&quot;观察文字&quot;;</span><br><span class="line">    </span><br><span class="line">    UITextField *field = [[UITextField alloc]initWithFrame:CGRectMake(20, 400, 200, 40)];</span><br><span class="line">    field.borderStyle = UITextBorderStyleRoundedRect;</span><br><span class="line">    [self.view addSubview:field];</span><br><span class="line">    [field nightWithType:ThemeTypeRed];</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">- (void)changeTheme&#123;</span><br><span class="line">    [ThemeManager shareInstance].night = ![ThemeManager shareInstance].isNight;</span><br><span class="line">    </span><br><span class="line">    [[NSUserDefaults standardUserDefaults] setBool:[ThemeManager shareInstance].isNight forKey:@&quot;THEME&quot;];</span><br><span class="line">    [[NSUserDefaults standardUserDefaults]synchronize];</span><br><span class="line">    [[NSNotificationCenter defaultCenter]postNotificationName:@&quot;CHANGECOLOR&quot; object:nil];</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">- (void)dealloc &#123;</span><br><span class="line">    [[NSNotificationCenter defaultCenter]removeObserver:self];</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="AppDelegate-中使用"><a href="#AppDelegate-中使用" class="headerlink" title="AppDelegate-中使用"></a>AppDelegate-中使用</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">#import &quot;AppDelegate.h&quot;</span><br><span class="line">#import &quot;ThemeManager.h&quot;</span><br><span class="line">#import &quot;UIView+Theme.h&quot;</span><br><span class="line">@interface AppDelegate ()</span><br><span class="line"></span><br><span class="line">@end</span><br><span class="line"></span><br><span class="line">@implementation AppDelegate</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions &#123;</span><br><span class="line">    [ThemeManager shareInstance].night = [[NSUserDefaults standardUserDefaults] boolForKey:@&quot;THEME&quot;];</span><br><span class="line">    </span><br><span class="line">    UITabBarController *tabbarVC = (UITabBarController *)self.window.rootViewController;</span><br><span class="line">    [tabbarVC.tabBar nightWithType:ThemeTypeNormal];</span><br><span class="line">    </span><br><span class="line">    return YES;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><a href="https://gitee.com/Min_amdrl/NightMode" target="_blank" rel="noopener"><strong>Demo</strong></a></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/10/17/WKWebView/" rel="next" title="WKWebView">
                <i class="fa fa-chevron-left"></i> WKWebView
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/10/29/MBProgress使用笔记/" rel="prev" title="MBProgress使用笔记">
                MBProgress使用笔记 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            Overview
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/10.png"
                alt="Erhqe" />
            
              <p class="site-author-name" itemprop="name">Erhqe</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">70</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                
                  <span class="site-state-item-count">31</span>
                  <span class="site-state-item-name">categories</span>
                
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                
                  <span class="site-state-item-count">1</span>
                  <span class="site-state-item-name">tags</span>
                
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#夜间模式"><span class="nav-number">1.</span> <span class="nav-text">夜间模式</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#ThemeManager-颜色管理者-H"><span class="nav-number">1.1.</span> <span class="nav-text">ThemeManager-颜色管理者.H</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#ThemeManager-颜色管理者-M"><span class="nav-number">1.2.</span> <span class="nav-text">ThemeManager-颜色管理者.M</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#UIView-Theme-UIView分类-H"><span class="nav-number">1.3.</span> <span class="nav-text">UIView+Theme-UIView分类.H</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#UIView-Theme-UIView分类-M"><span class="nav-number">1.4.</span> <span class="nav-text">UIView+Theme-UIView分类.M</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#UINavigationBar-Theme-导航条分类-M"><span class="nav-number">1.5.</span> <span class="nav-text">UINavigationBar+Theme-导航条分类.M</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#UITabBarItem-Theme-H-菜单按钮文字颜色"><span class="nav-number">1.6.</span> <span class="nav-text">UITabBarItem+Theme.H-菜单按钮文字颜色</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#UITabBarItem-Theme-M-也是一样的"><span class="nav-number">1.7.</span> <span class="nav-text">UITabBarItem+Theme.M-也是一样的</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#UITabBar-Theme-M-菜单栏底部"><span class="nav-number">1.8.</span> <span class="nav-text">UITabBar+Theme.M-菜单栏底部</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#UILabel-Theme-M"><span class="nav-number">1.9.</span> <span class="nav-text">UILabel+Theme.M</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#ViewController-中使用"><span class="nav-number">1.10.</span> <span class="nav-text">ViewController-中使用</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#AppDelegate-中使用"><span class="nav-number">1.11.</span> <span class="nav-text">AppDelegate-中使用</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Erhqe</span>

  
</div>


  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  










  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: false,
        notify: false,
        appId: 'TiAY2J24ECwQH9uLYsoJpgIK-gzGzoHsz',
        appKey: 'Y9PiVrPXVmfNsv4Aa6cPsADG',
        placeholder: 'Just go go',
        avatar:'mm',
        guest_info:guest,
        pageSize:'10' || 10,
    });
  </script>



  





  

  

  

  
  

  

  

  

</body>
</html>
